﻿using Collections.Pooled;
using furion.blog.Domain.Shared.Attribute;
using furion.blog.Domain.Shared.Vo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace furion.blog.Domain.Shared.Enum
{
    public enum SexEnum
    {
        /// <summary>
        /// 房源
        /// </summary>
        [EnumAttribute(Name = "男", Desc = "男", Value = "Man")]
        Man,
        /// <summary>
        /// 招聘
        /// </summary>
        [EnumAttribute(Name = "女", Desc = "女", Value = "Woman")]
        Woman,
        /// <summary>
        /// 家政
        /// </summary>
        [EnumAttribute(Name = "未知", Desc = "未知", Value = "Unknow")]
        Unknow,
    }


    public class Sex
    {
        public static async Task<PooledSet<NameValueVO>> Items()
        {
           return await Task.Run(() =>
            {
                PooledSet<NameValueVO> ret = new PooledSet<NameValueVO>();
                Type t = typeof(SexEnum);
                FieldInfo fd = null;
                foreach (var name in t.GetEnumNames())
                {
                    fd = t.GetField(name);
                    var attr = fd.GetCustomAttribute(typeof(EnumAttribute), false) as EnumAttribute;
                    ret.Add(new NameValueVO { Name = attr.Name, Value = attr.Value });
                }
                return ret;
            });
        }
    }

}
